package com.telit.firecommand.feign;

import com.telit.common.entity.DataReturn;
import com.telit.firecommand.feign.factory.FileFeignClientFallbackFactory;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * windows file 服务
 *
 * @author yuezhuang
 * @date 2022-10-20
 */
@FeignClient(name = "file", url = "${forest.file.windows.url}", fallbackFactory = FileFeignClientFallbackFactory.class)
public interface FileFeignClient {

    /**
     * 视频下载
     *
     * @param userId          用户id
     * @param cameraIndexCode 监控点唯一标识
     * @param beginTime       开始时间
     * @param endTime         结束时间
     * @param recordLocation  录像存储位置（0-中心存储，1-设备存储）,默认中心存储
     * @param callback        回调地址，用于通知communicate服务
     *
     * @return DataReturn Obj
     */
    @GetMapping(value = "/file/camera-monitor/downloadVideo", produces = MediaType.APPLICATION_JSON_VALUE)
    DataReturn downloadVideo(@RequestParam(value = "userId") String userId,
                             @RequestParam(value = "cameraIndexCode") String cameraIndexCode,
                             @RequestParam(value = "beginTime") String beginTime,
                             @RequestParam(value = "endTime") String endTime,
                             @RequestParam(value = "recordLocation") String recordLocation,
                             @RequestParam(value = "callback") String callback);

    /**
     * 查询是否下载完成
     *
     * @param userId          用户id
     * @param cameraIndexCode 监控点唯一标识
     *
     * @return DataReturn Obj
     */
    @GetMapping(value = "/file/camera-monitor/queryIsDownloadByCameraId", produces = MediaType.APPLICATION_JSON_VALUE)
    DataReturn queryIsDownloadByCameraId(@RequestParam(value = "userId") String userId,
                                         @RequestParam(value = "cameraIndexCode") String cameraIndexCode);

    /**
     * 下载文件
     *
     * @param fileName 文件名称
     */
    @GetMapping(value = "/file/camera-monitor/download", consumes = MediaType.APPLICATION_PROBLEM_JSON_VALUE)
    Response download(@RequestParam(value = "fileName") String fileName);

    /**
     * 删除文件
     *
     * @param fileName 文件名称
     *
     * @return DataReturn Obj
     */
    @GetMapping(value = "/file/camera-monitor/delete")
    DataReturn delete(@RequestParam(value = "fileName") String fileName);

}
